using System;
using System.Collections.Generic;
using System.Text;

namespace NBusiness.CodeDom.Compiler
{
    [Serializable]
    public class EntityResourceFile
    {
        public EntityResourceFile()
        { }
        public EntityResourceFile(string fileName, EntityBuildAction action)
        {
            _fileName = fileName;
            _action = action;
        }
        private EntityBuildAction _action = EntityBuildAction.Compile;

        public EntityBuildAction Action
        {
            get { return _action; }
            set { _action = value; }
        }

        private string _fileName;

        public string FileName
        {
            get { return _fileName; }
            set { _fileName = value; }
        }

        private byte[] _data;

        public byte[] Data
        {
            get { return _data; }
            set { _data = value; }
        }

        public static string[] GetCompileFiles(EntityResourceFile[] files)
        {
            List<string> names = new List<string>();
            foreach (EntityResourceFile file in files)
            {
                if (file.Action == EntityBuildAction.Compile)
                {
                    names.Add(file.FileName);
                }
            }
            return names.ToArray();
        }

        internal static string[] GetEmbeddedFiles(EntityResourceFile[] files)
        {
            List<string> names = new List<string>();
            foreach (EntityResourceFile file in files)
            {
                if (file.Action == EntityBuildAction.EmbeddedResource)
                {
                    names.Add(file.FileName);
                }
            }
            return names.ToArray();
        }
    }
}
